package com.filetransfer.view.Components.render;
import lombok.Getter;

import javax.swing.*;
import java.awt.*;
public class MessageViewButton extends JPanel {
    @Getter
    private final JButton viewButton;
    private final JLabel noMessageLabel;
    public MessageViewButton() {
        setLayout(new BorderLayout());
        viewButton = new JButton("查看");
        noMessageLabel = new JLabel("暂无", SwingConstants.CENTER);
        noMessageLabel.setForeground(Color.GRAY);
        // 配置按钮
        viewButton.setFocusPainted(false);
        viewButton.setBorderPainted(false);
        viewButton.setOpaque(false);
        add(viewButton, BorderLayout.CENTER);
    }
    public void configureButton(String message) {
        removeAll();
        if (message == null || message.trim().isEmpty()) {
            add(noMessageLabel, BorderLayout.CENTER);
        } else {
            add(viewButton, BorderLayout.CENTER);
        }
        revalidate();
        repaint();
    }
}
